<?php

use yii\db\Migration;

class m201112_012804_addon_app_versions extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_app_versions}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
            'title' => "varchar(255) NULL DEFAULT '' COMMENT '标题'",
            'cate_name' => "varchar(100) NULL DEFAULT '' COMMENT '分类标识'",
            'version_id' => "bigint(20) NULL DEFAULT '1' COMMENT '版本号ID'",
            'version' => "varchar(30) NOT NULL DEFAULT '' COMMENT '新版本号'",
            'package_size' => "varchar(30) NOT NULL DEFAULT '' COMMENT '包大小'",
            'type' => "tinyint(1) NULL COMMENT '类型 1:安卓;2;苹果'",
            'content' => "varchar(500) NOT NULL DEFAULT '' COMMENT '升级内容'",
            'download_url' => "varchar(255) NOT NULL DEFAULT '' COMMENT '下载地址'",
            'is_enforce' => "tinyint(1) unsigned NULL DEFAULT '0' COMMENT '强制更新'",
            'download_num' => "int(10) unsigned NULL DEFAULT '0' COMMENT '下载量'",
            'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态'",
            'created_at' => "int(10) unsigned NULL COMMENT '创建时间'",
            'updated_at' => "int(10) unsigned NULL COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT='版本表'");
        
        /* 索引设置 */

        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_app_versions}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

